<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
		








<link rel="stylesheet" type="text/css" href="/cbweb/jsp/resource/css/default.css">
<link rel="stylesheet" type="text/css" href="/cbweb/resource/css/public.css">
<link rel="stylesheet" type="text/css" href="/cbweb/resource/css/ddspstyle.css">
<link rel="stylesheet" type="text/css" href="/cbweb/plug-in/jquery/easyui/themes/default/easyui.css" id="easyuiTheme">
<link rel="stylesheet" type="text/css" href="/cbweb/plug-in/jquery/easyui/themes/icon.css">

<script type="text/javascript" src="/cbweb/plug-in/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/cbweb/plug-in/jquery/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/cbweb/plug-in/jquery/easyui/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript" src="/cbweb/resource/common/js/extEasyUI.js"></script>
<script type="text/javascript" src="/cbweb/resource/common/js/ajaxInterceptor.js"></script>

<script type="text/javascript" src="/cbweb/plug-in/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="/cbweb/plug-in/jquery/validate/formValidator.js"></script>
<script type="text/javascript" src="/cbweb/plug-in/jquery/validate/formValidatorRegex.js"></script>

<!--<script type="text/javascript" src="/cbweb/resource/plugin/kindeditor/kindeditor-min.js"></script>-->

<script type="text/javascript" src="/cbweb/resource/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/cbweb/resource/js/ueditor/ueditor.all.min.js"></script>
<!--<link  href="/cbweb/resource/js/ueditor/themes/default/css/ueditor.css" rel="stylesheet" type="text/css"/>-->
<!--<script type="text/javascript" src="/cbweb/resource/js/ueditor/lang/zh-cn/zh-cn.js"></script>-->
<script type="text/javascript" src="/cbweb/resource/js/app.js"></script>




<script type="text/javascript">
document.onkeydown=function(event){
            var e = event || window.event || arguments.callee.caller.arguments[0];
             if(e && e.keyCode==13){ // enter 键
             try { 
                  searchData();
                  } catch (e) { 
                  gotoSearch($('#easyui-treegrid'));
            	}
            }
        }; 
        
        </script>
<!--	<script type="text/javascript" src="/cbweb/plug-in/jquery/easyui/datagrid-detailview.js"></script>-->
	<script type="text/javascript" src="/cbweb/resource/js/app.js"></script>
	<style type="text/css">
		.imgsw{  background:url(../resource/images/a0133.png) no-repeat;  height:14px; width:17px; display:inline-block; border:0;
		}
	</style>
	<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid(){
			$("#easyui-datagrid").datagrid({
				url: '/cbweb/vchannel/medialist.html',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{ field:'id',checkbox:true },
					{field:'templatename',title:'所属客户',align:'center',width:150},
					{field:'name',title:'视频名称',align:'center',width:150},
					{field:'filepath',title:'位置',align:'center',width:150},
					{field:'addtime',title:'添加时间',align:'center',width:150,
						formatter : function(value, row, index) {
							if (value) {
								return new Date(value)
										.Format("yyyy-MM-dd");
							} else {
								return '';
					}

						}},
					{  //0未审核，1.已审核，2.已上传，8，审核不通过
						field : 'status',
						title : '状态',
						align : 'center',
						formatter : function(value, row, index) {
							if (value ==0) {
								return "未审核";
							} else if (value ==1) {
								return "通过接口验证";
							} else if (value == 8) {
								return "审核不通过";
							} else if (value == 4) {
								return "转码中";
							}
						}
					},
					{field:'_parentId',title:'操作',width:80,align:'center',
						formatter:function(value,row,index){
							str ="";
							
								str= '<a id="" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-remove" href="javascript:void(0);" onclick="onClickBtnDelete(\''+row.id+'\');"><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
							
					    	return str;
				    	}
					}
				]],
				singleSelect:false,
				pagination: true,
		        //view: detailview,
				pageList: [10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				onExpandRow: function(index,row){
				},
				onSelect: function(rowIndex,rowData) {
				},
				onUnselect: function(rowIndex,rowData) {
				},
				onCheckAll: function(rowIndex,rowData) {
				},
				onUncheckAll: function(rowIndex,rowData) {
				},
				onLoadSuccess: function (data) {
					
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/cbweb';
						    return false;
							}});
					}
					}
			});
	    }
		
		function getGueryParams(){
			return {
				tmpid:$("#tmpid").val(),
				name:$("#name").val(),
				status : $("#status").val()
			};
		}
		
		$(function(){
			new EasyuiDatagrid();
		
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
			onClickBtnDelete = function(id){
				$.messager.defaults={ok:"确定",cancel:"取消"};
				$.messager.confirm('确认删除直播视频', '确认删除直播视频么？', function(r){
					if (r){
						$.ajax({
							type: "POST",
							url: '/cbweb/vchannel/mediadelete.html?id='+id,
							dataType: "json",
							success : function(result) {
								if (result.success == true) {
									alert( result.object
											+ "个直播视频"
											+ "删除成功！");
									if (checkAjaxRequestValidity(result)) {
										gotoSearch($('#easyui-treegrid'));
									}
								} else {
									alert("直播视频删除失败");
								}

							},
							error: function(msg){
								alert("直播视频"+"删除异常，请联系管理员！");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
						});
					}
				});
			};
		});
		function deleteAll(){
			var ids="";
			$("input[name='id']:checkbox:checked").each(function(){
		    	 ids+=$(this).val()+",";
		         });
		     if(ids=="") {
		     	$.messager.alert('提示', '请至少选择一条数据', 'warning');
		     	return false;
		      } 
		    $.messager.defaults={ok:"确定",cancel:"取消"};
			$.messager.confirm('确认删除', '确认删除直播视频么？', function(r){
				if (r){
				
					$
					.ajax({
						type : "POST",
						url : '/cbweb/vchannel/mediadelete.html?id='
								+ids,
						dataType : "json",
						success : function(result) {
							if (result.success == true) {
								alert( result.object
										+ "个直播视频"
										+ "删除成功！");
								if (checkAjaxRequestValidity(result)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("直播视频删除失败!");
							}

						},
						error : function(result) {
							alert("直播视频"+ "删除异常，请联系管理员");
							if ($.isFunction(window.showMessager)) {
								window.showMessager(result.resultTitle,result.result);
							}
						}
					});
					}
				});	         
		}
		function SubgridTabOnSelect(title,index){
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},300);
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},3000);
	    }
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
		}
		
		function _resert(){
			$("#name").val("");
		}
		
		function onpress(){
		var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
   		  	if (event.keyCode == 13){  
      			gotoSearch($('#easyui-treegrid'));
    		}
		}
		
		function show(id) {
			openDialog($("#dlg"),'/cbweb/directory/editindex.html?id='+id);
		}
		
		function edit(){
			if($('#easyui-datagrid').datagrid('getSelected')==null){
				alert("请先选择一条数据");
				return false;
			}
			var row = $('#easyui-datagrid').datagrid('getSelected').id;
			openDialog($("#dlg"),'/cbweb/directory/editindex.html?id='+row);
		}
		
		function add(){
			openDialog($('#dlg'),'/cbweb/vchannel/mediaadd.html');
		}
		
		function changeGotoSearch() {
			gotoSearch($('#easyui-datagrid'));
			$('#openselect').dialog('close');
		}
		
		function openselect(){			
			openDialog($('#openselect'),'/cbweb/openselect/templates.html');
		}
	</script>
	
  </head>
  <body onload="load();">
	<table id="easyui-datagrid"  title="直播视频管理"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar"  style="" >
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table  cellspacing="0" cellpadding="0" width="90%">
			<tr>
			
			<td align="right" width="15%">视频名称：</td>
				 <td align="left"><input name="name" id="name" style="width: 130px;" onkeydown="onpress();"/></td>
				<td align="right" width="15%">行业客户：</td>
				<td>
				  <input name="userName" id="epgName" style="width: 150px;" onkeydown="onpress();" value="114新零售" readonly="true"/>
				  <input name="tmpid" id="tmpid" style="width: 150px;" type="hidden" value="12389"/>
				  <a class="easyui-linkbutton" data-options="iconCls:'icon-search', plain:true" onclick="openselect()"  href="javascript:void(0)">请选择</a>
				</td>
				</tr>
				<tr> 
				 <td align="right" width="15%">状态：</td>
						<td><select id="status" name="status" style="width: 130px;">
								<option value="">全部</option>
								<option value="0">未审核</option>
								<option value="8">审核未通过</option>
								<option value="1">通过接口验证</option>
								<option value="4">转码中</option>
						</select></td>
			    </tr>
			    <tr> 
		<td colspan="4" align="center">
				  <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search', plain:true" onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
				<!--  <a href="javascript:void(0);" class="easyui-linkbutton" data-options=" plain:true" onclick="_resert()">重置</a>-->
			   </td>
			</tr>
			</table>
			</form>
		</div>
		<div style="margin-bottom:5px">
		
	            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add();" iconCls="icon-add" plain="true">添加</a>
	         
	         
	            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteAll();" iconCls="icon-remove" plain="true">批量删除</a>
	         
	        </div>
	</div>
	 
	   <div id="openselect" class="easyui-dialog" style="width:550px;height:430px;padding-top: 0px;"
		    data-options="title: '行业客户选择', iconCls:'icon-save',modal:true,closed:true,buttons:'#openselect_buttons'">
		   	<iframe scrolling="auto" frameborder="0" style="width:100%;height:99%;"></iframe>
	   </div>
	     <div id="dlg" class="easyui-dialog" style="width:780px;height:500px;padding-top: 0px;"
    	 data-options="title: '添加视频', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
   		<iframe scrolling="auto" frameborder="0" style="width:100%;height:99%;"></iframe>
   		</div>
	   <div id="openselect_buttons" style="display: none;text-align: center;">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:changeGotoSearch()">确定</a>
	        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#openselect').dialog('close')">取消</a>
	   </div>
  </body >
</html>